import Mock from 'mockjs';

const code = 200;
export let getUserList = () => {
  return {
    data: Mock.mock({
      'list|10': [{
        'userId|+1': 1,
        'username': "@cname",
        'date': '@date',
        'address': '@region'
      }]
    }),
    code: code
  }
}

// 返回字符串
Mock.mock('/api/data', (req: any, res: any) => {
  return Mock.mock({
      'string|3': '*'
  })
})

// 返回指定范围的整数
Mock.mock('/api/getInteger', (req: any, res: any) => {
  return Mock.mock({
      'a|1-100': 100
  })
})

// 返回随机个数的对象
Mock.mock('/api/getObject', (req: any, res: any) => {
  return Mock.mock({
      'brand|1-3': {
          a: '京东',
          b: '国美',
          c: '苏宁',
          d: '当当',
          e: '天猫',
          f: '淘宝'
      }
  })
})

// 返回随机数组
Mock.mock('/api/getArr', (req: any, res: any) => {
  return Mock.mock({
      'data|1-10': [
        {
          'name': '张三'
        }
      ]
    })
})

// 返回随机字符
Mock.mock('/api/getRandom1', (req: any, res: any) => {
  return Mock.mock({
      'random1': /[a-z]{2}[A-Z]{2}[0-9]/
  })
})

// 返回随机字符
Mock.mock('/api/getRandom2', (req: any, res: any) => {
  return Mock.mock({random2: '@string("lower", 5)'})
})

// 返回UUID
Mock.mock('/api/getUUID', (req: any, res: any) => {
  return {'uuid': Mock.Random.id()}
})